/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.com.cotelasa.scp.controlador;

import java.io.Serializable;
import javax.faces.event.ActionEvent;
import javax.inject.Inject;
import org.apache.log4j.Logger;
import javax.inject.Named;
import org.springframework.context.annotation.Scope;
import pe.com.cotelasa.common.controlador.MBGenerico;
import pe.com.cotelasa.scp.common.IObserver;
import pe.com.cotelasa.scp.common.ISubject;
import pe.com.cotelasa.scp.controlador.backingBean.BKCompraDetalleNotaDebito;
import pe.com.cotelasa.scp.entidad.CompraDetalleNotaDebito;

/**
 *
 * @author WINDOWS 7
 */
@SuppressWarnings("serial")
@Named(value = "MBCompraDetalleNotaDebito")
@Scope("request")
public class MBCompraDetalleNotaDebito extends MBGenerico implements ISubject, Serializable {

    private static Logger logger = Logger.getLogger(MBCompraDetalleNotaDebito.class);
    @Inject
    private BKCompraDetalleNotaDebito bk;

    public void cargaInicial(ActionEvent actionEvent) {
        bk.setDetalleNotaDebito(new CompraDetalleNotaDebito());
        bk.setUpdate((String) actionEvent.getComponent().getAttributes().get("update"));
        bk.setDialog((String) actionEvent.getComponent().getAttributes().get("dialog"));
    }

    public void clearObserver() {
        bk.getObservers().clear();
    }

    @Override
    public void addObserver(IObserver observador) {
        bk.addObservers(observador);
    }

    @Override
    public void notificarObservadores() {
        for (IObserver observer : bk.getObservers()) {
            observer.actualizarObservador(bk.getDetalleNotaDebito());
        }
    }
}
